import Vue from 'vue'
import Router from 'vue-router'
import Index from '../components/system/index/index'

// 页面路由组件
import home from '../views/system/index/home'
import page404 from '../views/system/404'
import ProjectRank from '../views/system/assess/ProjectRank'
import loginRegister from '../views/system/login/loginRegister'
/*import projectDetails from '../views/system/assess/projectDetails'*/
import salary from'../views/system/assess/HomeView'
import Assess from '../views/system/assess/assess'
import  detail from '../views/system/assess/HelloWorld'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect:'/login'
    },
    {
      path:'/login',
      name:'loginRegister',
      component:loginRegister
    },

    {
      path:'/index',
      name:Index,
      component:Index,
      children:[
        {
          path:'/home',
          name:home,
          component:home,
        },
        {
          path:'/salary',
          name:'salary',
          component:salary
        },
         {
          path:'/assess',
          name:Assess,
          component:Assess,
        },
  {
          path:'/detail',
          name:detail,
          component:detail,
        },

        {
          path:'/rank',
          name:ProjectRank,
          component:ProjectRank,
        },
      /*  {
          path:'/detail',
          name:'projectDetails',
          component:projectDetails
        },*/

      ]
    },
    {
      path: '/404',
      name:'Page404',
      component:page404,
    },
    { path: '*', redirect: '/404', hidden: true }
  ]
})

/*router.beforeEach((to, from, next) => {
  // 1. 判断是不是登录页面
  // 是登录页面
  if(to.path === '/login') {
    next()
  } else {
    // 不是登录页面
    // 2. 判断 是否登录过
    let token = localStorage.getItem('token')
    token ? next({path:'/home'}) : next('/login')
  }
})*/

